package com.tjsinfo.tjsoa.mail.bo;

import com.tjsinfo.tjsoa.mail.dao.ITjsUserEmailDao;
import com.tjsinfo.tjsoa.mail.vo.TjsUserEmail;
import com.tjsinfo.tjsoa.system.vo.TSystemUser;


public class TjsUserEmailBo implements ITjsUserEmailBo{
	private final boolean STARTTRUE = true;
	private final boolean STARTFALSE = false;
	private ITjsUserEmailDao tjsUserEmailDao;
	
	public ITjsUserEmailDao getTjsUserEmailDao() {
		return tjsUserEmailDao;
	}

	public void setTjsUserEmailDao(ITjsUserEmailDao tjsUserEmailDao) {
		this.tjsUserEmailDao = tjsUserEmailDao;
	}

	public boolean deleteMailUser(String mailid) {
		// TODO Auto-generated method stub
		try {
			TjsUserEmail  tjsUserEmail = selectOneMail(mailid);//用户邮件
			tjsUserEmailDao.delete(tjsUserEmail);
			return STARTTRUE;
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return STARTFALSE;
		}
		
	}

	public boolean initUserMail(Integer userid, Integer size,
			Integer fujiansize, String smtp, String pop3) {
		// TODO Auto-generated method stub
		try {
			TjsUserEmail tjsUserEmail = new TjsUserEmail();//用户邮件
			TSystemUser tjsUser = new TSystemUser();

			tjsUser.setUserId(userid);
			tjsUserEmail.setTjsUser(tjsUser);
			tjsUserEmail.setUserEmailSize(size);
			tjsUserEmail.setUserEmailFujiansize(fujiansize);
			tjsUserEmail.setUserEmailKeyongsize(size);
			tjsUserEmail.setUserEmailPop3(pop3);
			tjsUserEmail.setUserEmailSmtp(smtp);
			tjsUserEmailDao.save(tjsUserEmail);
			return STARTTRUE;
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return STARTFALSE;
		}
		
	}

	public boolean initUserMail(Integer userid, Integer size, Integer fujiansize) {
		// TODO Auto-generated method stub
	
		try {
			TjsUserEmail tjsUserEmail = new TjsUserEmail();//用户邮件
			TSystemUser tjsUser = new TSystemUser();
			tjsUser.setUserId(userid);
			tjsUserEmail.setTjsUser(tjsUser);
			tjsUserEmail.setUserEmailSize(size);
			tjsUserEmail.setUserEmailFujiansize(fujiansize);
			tjsUserEmail.setUserEmailKeyongsize(size);
			tjsUserEmailDao.save(tjsUserEmail);
			return STARTTRUE;
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return STARTFALSE;
		}
	}

	public boolean isMailBoxKeYong(Integer userid, String mailboxid) {
		// TODO Auto-generated method stub
		return false;
	}

	public TjsUserEmail selectOneMail(String id) {
		// TODO Auto-generated method stub
		return tjsUserEmailDao.selectById(id);
	}

	public boolean updateMailBoxKeYongSize(String mailid) {
		// TODO Auto-generated method stub
		return false;
	}
	
}
